// IFolder.h

#ifndef __IFOLDER_H
#define __IFOLDER_H

#include "Common/Stream/IProgress.h"
#include "Common/Stream/IStream.h"

namespace Common
{
namespace FileSystem
{
//used only in RegistryPlugins.cpp
  enum class Plugin
  {
    kName = 0,
    kType,
    kClassID,
    kOptionsClassID
  };

}
}

MIDL_INTERFACE("23170F69-40C1-278A-0000-000800000000")
IFolderFolder: public IUnknown
{
	STDMETHOD(LoadItems)() PURE;
	STDMETHOD(GetNumberOfItems)(UINT32 *numItems) PURE;
	STDMETHOD(GetProperty)(UINT32 itemIndex, PROPID propID, PROPVARIANT *value) PURE;
	STDMETHOD(BindToFolder)(UINT32 index, IFolderFolder **resultFolder) PURE;
	STDMETHOD(BindToFolder)(const wchar_t *name, IFolderFolder **resultFolder) PURE;
	STDMETHOD(BindToParentFolder)(IFolderFolder **resultFolder) PURE;
	STDMETHOD(GetNumberOfProperties)(UINT32 *numProperties) PURE;
	STDMETHOD(GetPropertyInfo)(UINT32 index, BSTR *name, PROPID *propID, VARTYPE *varType) PURE;
	STDMETHOD(GetFolderProperty)(PROPID propID, PROPVARIANT *value) PURE;
};

MIDL_INTERFACE("23170F69-40C1-278A-0000-000800040000")
IFolderWasChanged: public IUnknown
{
  STDMETHOD(WasChanged)(INT32 *wasChanged) PURE;
};

MIDL_INTERFACE("23170F69-40C1-278A-0000-0008000B0000")
IFolderOperationsExtractCallback: public IProgress
{
  // STDMETHOD(SetTotalFiles)(UINT64 total) PURE;
  // STDMETHOD(SetCompletedFiles)(const UINT64 *completedValue) PURE;
  STDMETHOD(AskWrite)(
      const wchar_t *srcPath,
      INT32 srcIsFolder,
      const FILETIME *srcTime,
      const UINT64 *srcSize,
      const wchar_t *destPathRequest,
      BSTR *destPathResult,
      INT32 *writeAnswer) PURE;
  STDMETHOD(ShowMessage)(const wchar_t *message) PURE;
  STDMETHOD(SetCurrentFilePath)(const wchar_t *filePath) PURE;
  STDMETHOD(SetNumFiles)(UINT64 numFiles) PURE;
};
 

MIDL_INTERFACE("23170F69-40C1-278A-0000-000800060000")
IFolderOperations: public IUnknown
{
	STDMETHOD(CreateFolder)(const wchar_t *name, IProgress *progress) PURE;
	STDMETHOD(CreateFile)(const wchar_t *name, IProgress *progress) PURE;
	STDMETHOD(Rename)(UINT32 index, const wchar_t *newName, IProgress *progress) PURE;
	STDMETHOD(Delete)(const UINT32 *indices, UINT32 numItems, IProgress *progress) PURE;
	STDMETHOD(CopyTo)(const UINT32 *indices, UINT32 numItems, 
      const wchar_t *path, IFolderOperationsExtractCallback *callback) PURE;
	STDMETHOD(MoveTo)(const UINT32 *indices, UINT32 numItems, 
      const wchar_t *path, IFolderOperationsExtractCallback *callback) PURE;
	STDMETHOD(CopyFrom)(const wchar_t *fromFolderPath, 
      const wchar_t **itemsPaths, UINT32 numItems, IProgress *progress) PURE;
	STDMETHOD(SetProperty)(UINT32 index, PROPID propID, const PROPVARIANT *value, IProgress *progress) PURE;
};

/*
FOLDER_INTERFACE2(IFolderOperationsDeleteToRecycleBin, 0x06, 0x03)
{
  STDMETHOD(DeleteToRecycleBin)(const UINT32 *indices, UINT32 numItems, IProgress *progress) PURE;
};
*/

MIDL_INTERFACE("23170F69-40C1-278A-0000-000800070000")
IFolderGetSystemIconIndex: public IUnknown
{
  STDMETHOD(GetSystemIconIndex)(UINT32 index, INT32 *iconIndex) PURE;
};

MIDL_INTERFACE("23170F69-40C1-278A-0000-000800080000")
IFolderGetItemFullSize: public IUnknown
{
  STDMETHOD(GetItemFullSize)(UINT32 index, PROPVARIANT *value, IProgress *progress) PURE;
};

MIDL_INTERFACE("23170F69-40C1-278A-0000-000800090000")
IFolderClone: public IUnknown
{
  STDMETHOD(Clone)(IFolderFolder **resultFolder) PURE;
};

MIDL_INTERFACE("23170F69-40C1-278A-0000-0008000A0000")
IFolderSetFlatMode: public IUnknown
{
  STDMETHOD(SetFlatMode)(INT32 flatMode) PURE;
}; 


//This interface cab be implemented in as a saparate class
MIDL_INTERFACE("23170F69-40C1-278A-0000-0008000E0000")
IFolderProperties: public IUnknown
{
	STDMETHOD(GetNumberOfFolderProperties)(UINT32 *numProperties) PURE; 
	STDMETHOD(GetFolderPropertyInfo)(UINT32 index, BSTR *name, PROPID *propID, VARTYPE *varType) PURE;
};

MIDL_INTERFACE("23170F69-40C1-278A-0000-000800100000")
IFolderArcProps: public IUnknown
{
  STDMETHOD(GetArcNumLevels)(UINT32 *numLevels) PURE;
  STDMETHOD(GetArcProp)(UINT32 level, PROPID propID, PROPVARIANT *value) PURE;
  STDMETHOD(GetArcNumProps)(UINT32 level, UINT32 *numProps) PURE;
  STDMETHOD(GetArcPropInfo)(UINT32 level, UINT32 index, BSTR *name, PROPID *propID, VARTYPE *varType) PURE;
  STDMETHOD(GetArcProp2)(UINT32 level, PROPID propID, PROPVARIANT *value) PURE;
  STDMETHOD(GetArcNumProps2)(UINT32 level, UINT32 *numProps) PURE;
  STDMETHOD(GetArcPropInfo2)(UINT32 level, UINT32 index, BSTR *name, PROPID *propID, VARTYPE *varType) PURE;
};

MIDL_INTERFACE("23170F69-40C1-278A-0000-000800110000")
IGetFolderArcProps: public IUnknown
{
  STDMETHOD(GetFolderArcProps)(IFolderArcProps **object) PURE;
};

  
  // STDMETHOD(GetTypes)(BSTR *types) PURE;
  // STDMETHOD(CreateFolderFile)(const wchar_t *type, const wchar_t *filePath, IProgress *progress) PURE;

MIDL_INTERFACE("23170F69-40C1-278A-0000-000900050000")
IFolderManager: public IUnknown
{
	STDMETHOD(OpenFolderFile)(IInStream *inStream, 
	  const wchar_t *filePath, const wchar_t *arcFormat, IFolderFolder **resultFolder, IProgress *progress) PURE;
	STDMETHOD(GetExtensions)(BSTR *extensions) PURE;
	STDMETHOD(GetIconPath)(const wchar_t *ext, BSTR *iconPath, INT32 *iconIndex) PURE;
};

//Extract it into a separate class

/*#define IMP_IFolderFolder_GetProp(k) \
  (UINT32 index, BSTR *name, PROPID *propID, VARTYPE *varType) \
    { if(index >= sizeof(k) / sizeof(k[0])) return E_INVALIDARG; \
    const STATPROPSTG &srcItem = k[index]; \
    *propID = srcItem.propid; *varType = srcItem.vt; *name = 0; return S_OK; } \

#define IMP_IFolderFolder_Props(c) \
  STDMETHODIMP c::GetNumberOfProperties(UINT32 *numProperties) \
    { *numProperties = sizeof(kProps) / sizeof(kProps[0]); return S_OK; } \
  STDMETHODIMP c::GetPropertyInfo IMP_IFolderFolder_GetProp(kProps) */

#endif
